package com.pvdnc.worldmagisk.shell.server;

import android.util.Log;

import com.pvdnc.worldmagisk.shell.Packet;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class CommandRequestHandler extends SimpleChannelInboundHandler<CommandRequest> {
    private static final String TAG= CommandRequestHandler.class.getSimpleName();
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, CommandRequest msg) throws Exception {
        Log.d(TAG,"on command request received");
        Log.d(TAG,"command:"+msg.mCommand);
        Packet packet=new Packet();
        packet.mType=Packet.TYPE_RESPONSE;
        packet.mData=msg.execute().getBytes();
        ctx.channel().writeAndFlush(packet);
    }
}
